// Tags:
#include <cctype>
#include <cstdio>
#include <cstring>

typedef long long ll;

template <typename T>
inline T &read(T &x) {
  x = 0;
  bool f = false;
  short ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = true;
    ch = getchar();
  }
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ '0'), ch = getchar();
  if (f) x = -x;
  return x;
}

const int N = 2e5 + 5;
int n;
ll preL, preLW;
char str[N];

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen64("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen64("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("hard.in", "r", stdin);
  freopen("hard.out", "w", stdout);
#endif
#endif

  scanf("%s", str), n = strlen(str);
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    if (str[i] == 'L') {
      ++preL;
    } else if (str[i] == 'W') {
      preLW += preL;
    } else if (str[i] == 'S') {
      ans += preLW;
    }
  }
  // if (str[0] == 'L' && str[1] == 'W' && str[2] == 'S') puts("1");
  // else
  //   puts("0");
  printf("%lld", ans);
  return 0;
}